import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { AnswerInfo } from './answerInfo.entity'

@Injectable()
export class AnswerInfoService {
  constructor(
    @InjectRepository(AnswerInfo)
    private repository: Repository<AnswerInfo>,
  ) {}

  /**
   * 查询一个回答的详情
   * @param answer_id 
   * @returns 
   */
  findAll_By_AnswerId(answer_id: number): Promise<AnswerInfo[]>{
    return this.repository.find({where:{answer_id:answer_id}});
  }

  /**
   * 查询视频id：根据任务id
   * @param trace_id 
   * @returns 
   */
  findOne_By_TraceId(trace_id: string): Promise<AnswerInfo>{
    return this.repository.findOne({where:{trace_id:trace_id}})
  }

  findAll(): Promise<AnswerInfo[]> {
    return this.repository.find();
  }

  findOne(id: any): Promise<AnswerInfo> {
    return this.repository.findOne(id);
  }

  async remove(id: number): Promise<void> {
    await this.repository.delete(id);
  }

  async create(cats: AnswerInfo): Promise<void> {
    await this.repository.save(cats);
  }
}
